@echo off
setlocal

REM 获取当前目录
set "current_dir=%~dp0"
echo 当前目录: %current_dir%

REM 删除旧的dist和build目录
echo 正在清理旧的构建文件...
if exist "%current_dir%dist" rmdir /s /q "%current_dir%dist"
if exist "%current_dir%build" rmdir /s /q "%current_dir%build"

REM 构建WordTableGeneratorUI.exe
echo 正在构建WordTableGeneratorUI.exe...
pyinstaller --noconfirm --onedir --windowed --name "WordTableGeneratorUI" ^
    --add-data "qt_material;qt_material/" ^
    --hidden-import qt_material ^
    "%current_dir%WordTableGeneratorUI.py"

REM 构建TextJoinerUI.exe
echo 正在构建TextJoinerUI.exe...
pyinstaller --noconfirm --onedir --windowed --name "TextJoinerUI" ^
    --add-data "qt_material;qt_material/" ^
    --hidden-import qt_material ^
    "%current_dir%TextJoinerUI.py"

echo.
echo 构建完成！
echo WordTableGeneratorUI.exe 位于 dist\WordTableGeneratorUI\
echo TextJoinerUI.exe 位于 dist\TextJoinerUI\
pause